package org.jeecg.modules.online.cgform.converter.impl;

import com.alibaba.fastjson.JSONArray;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.modules.online.cgform.converter.channel.ForeseeConvert;
import org.jeecg.modules.online.cgform.entity.OnlCgformField;

import java.util.ArrayList;
import java.util.List;

/**
 * 开关
 */
public class SwitchConverter extends ForeseeConvert {

    public SwitchConverter(OnlCgformField onlCgformField){
        String extData = onlCgformField.getFieldExtendJson();
        String y = "Y", n = "N";
        if(extData!=null && !"".equals(extData)){
            JSONArray array = JSONArray.parseArray(extData);
            if(array!=null && array.size()==2){
                y = array.get(0).toString();
                n = array.get(1).toString();
            }
        }
        List<DictModel> dictList = new ArrayList<DictModel>();
        DictModel yDict = new DictModel(y, "是");
        DictModel nDict = new DictModel(n, "否");
        dictList.add(yDict);
        dictList.add(nDict);
        this.dictList = dictList;
        this.filed = onlCgformField.getDbFieldName();
    }
}
